`include "all.sv"

module top_NewLabel;
  `include "NewLabel_test_lib.sv"
  
  bit sclk, cclk, mclk, 
  rst_n;
  SysIf	sysif0(.*);
  MemIf memif0(.*);
  
NewLabel_top dut0(
	.arstn(rst_n),
	.cclk(cclk),
	.sclk(sclk),
	.mclk(mclk),

	.data_s(sysif0.data),
	.addr_s(sysif0.addr),
	.cs_s(sysif0.cs),
	.wr_s(sysif0.wr),
	.wr_full_s(sysif0.wr_full_flag),
	.rd_empty_s(sysif0.rd_empty_flag),

	// auxmem if
	.data_m(memif0.data_m),
	.addr_m(memif0.addr_m),
	.cs_m(memif0.cs_m),
	.gpctrl_m(memif0.gpctrl_m),

	// Others
	.err_s(),
	.finish_s(memif0.finish_s)
);

  always #(10/2) sclk = !sclk;
  always #(1.25)	cclk = !cclk;	//400Mhz
  //always #(1.5)	cclk = !cclk;	//333Mhz
  //always #(2)	cclk = !cclk;	//250Mhz  
  //always #(2.5)	cclk = !cclk;	//200Mhz
  //always #(3)	cclk = !cclk;	//166Mhz
  always #(10/2) mclk = !mclk;
  
  initial begin
    //run_test("test_NewLabel_16X16_Special");
    //run_test("test_NewLabel_128X128_Special");
    //run_test("test_NewLabel_256X256_Special");
    run_test("test_NewLabel_512X512_Special");
  end
  
  initial begin
    rst_n = 0;
    #21;
    rst_n = 1;
  end    

  integer fp0;
  integer fp1;
  integer fp2;
  integer fp3;
  string ImgName = "512_60";
  initial begin
  	fp0 = $fopen($psprintf("./testImg_perfData/%s_fifo_out_s.txt", ImgName));
  	$fmonitor(fp0, "%s_fifo_out_s: rd_status = %d, wr_status = %d, time = %d",
  					ImgName,
  					dut0.shell_inst.fifo_out_s.rptr_empty.rd_status,
					dut0.shell_inst.fifo_out_s.wptr_full.wr_status,
					$realtime);
	fp1 = $fopen($psprintf("./testImg_perfData/%s_fifo_in_s.txt", ImgName));
  	$fmonitor(fp1, "%s_fifo_in_s: rd_status = %d, wr_status = %d, time = %d", 
  					ImgName,
  					dut0.shell_inst.fifo_in_s.rptr_empty.rd_status,
					dut0.shell_inst.fifo_in_s.wptr_full.wr_status,
					$realtime);
	fp2 = $fopen($psprintf("./testImg_perfData/%s_fifo_out_am.txt", ImgName));
  	$fmonitor(fp2, "%s_fifo_out_am: rd_status = %d, wr_status = %d, time = %d",
  					ImgName,
  					dut0.shell_inst.fifo_out_am.rptr_empty.rd_status,
					dut0.shell_inst.fifo_out_am.wptr_full.wr_status,
					$realtime);
	fp3 = $fopen($psprintf("./testImg_perfData/%s_fifo_in_am.txt", ImgName));
  	$fmonitor(fp3, "%s_fifo_in_am: rd_status = %d, wr_status = %d, time = %d", 
  					ImgName,
  					dut0.shell_inst.fifo_in_am.rptr_empty.rd_status,
					dut0.shell_inst.fifo_in_am.wptr_full.wr_status,
					$realtime);
	/*if(root.finish_on_completion)
	begin
		$fclose(fp0);
		$fclose(fp1);
		$fclose(fp2);
		$fclose(fp3);
	end*/
  end
  
endmodule : top_NewLabel
